package com.fs.procure.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.core.vo.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.common.util.page.PageUtils;
import com.fs.procure.pojo.AddProduct;
import com.fs.procure.pojo.Addvariant;
import com.fs.procure.vo.AddProductVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fs.procure.service.IAddProductService;


/**
 * 进货商品信息Controller
 * 
 * @author lan
 * @date 2024-08-15
 */
@RestController
@RequestMapping("/procure/product")
public class AddProductController extends BaseController
{
    @Autowired
    private IAddProductService productService;

    /**
     * 查询进货商品信息列表
     */
    @PreAuthorize("@ss.hasPermi('procure:product:list')")
    @GetMapping("/list")
    public TableDataInfo list(AddProduct addproduct)
    {
        PageUtils.startPage();
        List<AddProduct> list = productService.selectProductList(addproduct);
        Page<AddProduct> page=new Page<>();
        page.setRecords(list);
        page.setTotal(list.size());
        return getDataTable(page);
    }

//
//    /**
//     * 新增进货商品信息
//     */
//    @PreAuthorize("@ss.hasPermi('procure:product:add')")
//    @Log(title = "进货商品信息", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody AddProduct product)
//    {
//        int i = productService.insertProduct(product);
//        return i>0?AjaxResult.success():AjaxResult.error();
//    }
    /**
     * 查询进货商品详细信息
     */
    @PreAuthorize("@ss.hasPermi('procure:product:list')")
    @GetMapping("/list1")
    public AjaxResult list(int productId)
    {
       AjaxResult ajaxResult=new AjaxResult();

        List<AddProductVo> list = productService.getAllAddvariant(productId);

      ajaxResult.put("list",list);


        return ajaxResult;
    }

}
